home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE20 / CLINIC / TSTCHKU4.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1997-01-28  |  1.0 KB  |  51 lines

  1. unit TstChkU4;
  2.  
  3. interface
  4.  
  5. uses
  6.   WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     Button2: TButton;
  13.     CheckBox1: TCheckBox;
  14.     procedure CheckBox1KeyDown(Sender: TObject; var Key: Word;
  15.       Shift: TShiftState);
  16.   private
  17.     { Private declarations }
  18.   public
  19.     procedure CMDialogKey(var Msg: TCMDialogKey);
  20.       message cm_DialogKey;
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.DFM}
  29.  
  30. procedure TForm1.CMDialogKey(var Msg: TCMDialogKey);
  31. begin
  32.   with Msg do
  33.     if (CharCode in [vk_Up, vk_Down]) and
  34.        (ActiveControl = CheckBox1) then
  35.       { Return 0 to stop the keystrokes being "absorbed" }
  36.       Result := 0
  37.     else
  38.       inherited
  39. end;
  40.  
  41. procedure TForm1.CheckBox1KeyDown(Sender: TObject; var Key: Word;
  42.   Shift: TShiftState);
  43. begin
  44.   case Key of
  45.     vk_Up: CheckBox1.Caption := 'Up';
  46.     vk_Down: CheckBox1.Caption := 'Down';
  47.   end;
  48. end;
  49.  
  50. end.
  51.